﻿// Y11ScannerExamples.cs
//
// Copyright 2008 by Burt Harris
// Licensed under the Microsoft Public License (Ms-PL)
// See: http://www.codeplex.com/yaml/license
//
// Portions Copyright © 2001-2008 Oren Ben-Kiki, Clark Evans, Ingy döt Net
// See: http://www.yaml.org/spec/1.1
//

using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace YaTools.Yaml.UnitTests
{
    /// <summary>
    /// Scanner level unit tests based on Yaml 1.1 spec.
    /// </summary>
    [TestClass]
    public class Y11ScannerExamples : YamlScannerTest
    {
        // ReSharper disable InconsistentNaming
        [TestMethod]
        public void Y11_10_04_Flow()
        {
            YamlTest(
                @"
%YAML 1.1
---
!!map {
  ? !!str ""block""
  : !!seq [
    !!str ""one"",
    !!seq [
      !!str ""two""
    ]
  ]
}
",
                Token.Directive,
                Token.DirectivesEnd,
                Token.Tag, Token.OpenBrace,
                Token.FlowKeyIndicator, Token.Tag, "block",
                Token.ValueIndicator, Token.Tag, Token.OpenBracket,
                Token.Tag, "one", Token.Comma, Token.Tag, Token.OpenBracket,
                Token.Tag, "two",
                Token.CloseBracket,
                Token.CloseBracket,
                Token.CloseBrace);
        }


        [TestMethod]
        public void Y11_02_01()
        {
            YamlTest(@"
- Mark McGwire
- Sammy Sosa
- Ken Griffey
",
                     Token.BlockSeqBegin, "Mark McGwire",
                     Token.BlockSeqNext, "Sammy Sosa",
                     Token.BlockSeqNext, "Ken Griffey",
                     Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_02_02()
        {
            YamlTest(@"
hr:  65
avg: 0.278
rbi: 147
",
                     Token.BlockMappingBegin,
                     Token.ImplicitKey, "hr",
                     Token.ValueIndicator, "65",
                     Token.ImplicitKey, "avg",
                     Token.ValueIndicator, "0.278",
                     Token.ImplicitKey, "rbi",
                     Token.ValueIndicator, "147",
                     Token.Outdent
                );
        }


        [TestMethod]
        public void Y11_02_03()
        {
            YamlTest(
                @"
american:  
  - Boston Red Sox
  - Detroit Tigers
  - New York Yankees
national:
  - New York Mets
  - Chicago Cubs
  - Atlanta Braves
",
                Token.BlockMappingBegin,
                Token.ImplicitKey, "american",
                Token.ValueIndicator,
                Token.BlockSeqBegin, "Boston Red Sox",
                Token.BlockSeqNext, "Detroit Tigers",
                Token.BlockSeqNext, "New York Yankees",
                Token.Outdent,
                Token.ImplicitKey, "national",
                Token.ValueIndicator,
                Token.BlockSeqBegin, "New York Mets",
                Token.BlockSeqNext, "Chicago Cubs",
                Token.BlockSeqNext, "Atlanta Braves",
                Token.Outdent,
                Token.Outdent
                );
        }


        [TestMethod]
        public void Y11_02_04()
        {
            YamlTest(
                @"
-  
  name: Mark McGwire
  hr:   65
  avg:  0.278
-
  name: Sammy Sosa
  hr:   63
  avg:  0.288

",
                Token.BlockSeqBegin,
                Token.BlockMappingBegin,
                Token.ImplicitKey, "name",
                Token.ValueIndicator, "Mark McGwire",
                Token.ImplicitKey, "hr",
                Token.ValueIndicator, "65",
                Token.ImplicitKey, "avg",
                Token.ValueIndicator, "0.278",
                Token.Outdent,
                Token.BlockSeqNext,
                Token.BlockMappingBegin,
                Token.ImplicitKey, "name",
                Token.ValueIndicator, "Sammy Sosa",
                Token.ImplicitKey, "hr",
                Token.ValueIndicator, "63",
                Token.ImplicitKey, "avg",
                Token.ValueIndicator, "0.288",
                Token.Outdent,
                Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_02_05()
        {
            YamlTest(@"

- [name        , hr, avg  ]
- [Mark McGwire, 65, 0.278]
- [Sammy Sosa  , 63, 0.288]

",
                     Token.BlockSeqBegin,
                     Token.OpenBracket, "name", Token.Comma, "hr", Token.Comma, "avg", Token.CloseBracket,
                     Token.BlockSeqNext,
                     Token.OpenBracket, "Mark McGwire", Token.Comma, "65", Token.Comma, "0.278", Token.CloseBracket,
                     Token.BlockSeqNext,
                     Token.OpenBracket, "Sammy Sosa", Token.Comma, "63", Token.Comma, "0.288", Token.CloseBracket,
                     Token.Outdent);
        }

        [TestMethod]
        public void Y11_02_06()
        {
            YamlTest(@"
Mark McGwire: {hr: 65, avg: 0.278}
Sammy Sosa: {
    hr: 63,
    avg: 0.288
  }

",
                     Token.BlockMappingBegin,
                     Token.ImplicitKey, "Mark McGwire", Token.ValueIndicator,
                     Token.OpenBrace,
                     Token.ImplicitKey, "hr", Token.ValueIndicator, "65", Token.Comma,
                     Token.ImplicitKey, "avg", Token.ValueIndicator, "0.278",
                     Token.CloseBrace,
                     Token.ImplicitKey, "Sammy Sosa", Token.ValueIndicator,
                     Token.OpenBrace,
                     Token.ImplicitKey, "hr", Token.ValueIndicator, "63", Token.Comma,
                     Token.ImplicitKey, "avg", Token.ValueIndicator, "0.288",
                     Token.CloseBrace,
                     Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_02_07()
        {
            YamlTest(
                @"
# Ranking of 1998 home runs
---
- Mark McGwire
- Sammy Sosa
- Ken Griffey

# Team ranking
---
- Chicago Cubs
- St Louis Cardinals
",
                Token.Comment,
                Token.DirectivesEnd,
                Token.BlockSeqBegin, "Mark McGwire",
                Token.BlockSeqNext, "Sammy Sosa",
                Token.BlockSeqNext, "Ken Griffey",
                Token.Outdent,
                Token.DirectivesEnd,
                Token.BlockSeqBegin, "Chicago Cubs",
                Token.BlockSeqNext, "St Louis Cardinals",
                Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_02_08()
        {
            YamlTest(
                @"
---
time: 20:03:20
player: Sammy Sosa
action: strike (miss)
...
---
time: 20:03:47
player: Sammy Sosa
action: grand slam
...
",
                Token.DirectivesEnd,
                Token.BlockMappingBegin,
                Token.ImplicitKey, "time", Token.ValueIndicator, "20:03:20",
                Token.ImplicitKey, "player", Token.ValueIndicator, "Sammy Sosa",
                Token.ImplicitKey, "action", Token.ValueIndicator, "strike (miss)",
                Token.Outdent,
                Token.DocumentEnd,
                Token.DirectivesEnd,
                Token.BlockMappingBegin,
                Token.ImplicitKey, "time", Token.ValueIndicator, "20:03:47",
                Token.ImplicitKey, "player", Token.ValueIndicator, "Sammy Sosa",
                Token.ImplicitKey, "action", Token.ValueIndicator, "grand slam",
                Token.Outdent,
                Token.DocumentEnd
                );
        }

        [TestMethod]
        public void Y11_02_09()
        {
            YamlTest(
                @"
---
hr: # 1998 hr ranking
  - Mark McGwire
  - Sammy Sosa
rbi:
  # 1998 rbi ranking
  - Sammy Sosa
  - Ken Griffey
",
                Token.DirectivesEnd,
                Token.BlockMappingBegin,
                Token.ImplicitKey, "hr", Token.ValueIndicator,
                Token.BlockSeqBegin, "Mark McGwire",
                Token.BlockSeqNext, "Sammy Sosa",
                Token.Outdent,
                Token.ImplicitKey, "rbi", Token.ValueIndicator,
                Token.BlockSeqBegin, "Sammy Sosa",
                Token.BlockSeqNext, "Ken Griffey",
                Token.Outdent,
                Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_02_10()
        {
            YamlTest(
                @"
---
hr:
  - Mark McGwire
  # Following node labeled SS
  - &SS Sammy Sosa
rbi:
  - *SS # Subsequent occurrence
  - Ken Griffey
",
                Token.DirectivesEnd,
                Token.BlockMappingBegin,
                Token.ImplicitKey, "hr",
                Token.ValueIndicator,
                Token.BlockSeqBegin, "Mark McGwire", Token.Comment,
                Token.BlockSeqNext, Token.Anchor, "Sammy Sosa",
                Token.Outdent,
                Token.ImplicitKey, "rbi",
                Token.ValueIndicator,
                Token.BlockSeqBegin, Token.Alias, Token.Comment,
                Token.BlockSeqNext, "Ken Griffey",
                Token.Outdent,
                Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_02_11()
        {
            YamlTest(
                @"
? - Detroit Tigers  
  - Chicago cubs
:
  - 2001-07-23

? [ New York Yankees,
    Atlanta Braves ]
: [ 2001-07-02, 2001-08-12,
    2001-08-14 ]

",
                Token.BlockMappingBegin,
                Token.BlockKeyIndicator,
                Token.BlockSeqBegin, "Detroit Tigers",
                Token.BlockSeqNext, "Chicago cubs",
                Token.Outdent,
                Token.ValueIndicator,
                Token.BlockSeqBegin, "2001-07-23",
                Token.Outdent,
                Token.BlockKeyIndicator,
                Token.OpenBracket,
                "New York Yankees", Token.Comma,
                "Atlanta Braves",
                Token.CloseBracket,
                Token.ValueIndicator,
                Token.OpenBracket,
                "2001-07-02", Token.Comma,
                "2001-08-12", Token.Comma,
                "2001-08-14",
                Token.CloseBracket,
                Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_02_12()
        {
            YamlTest(
                @"
---
# products purchased
- item    : Super Hoop
  quantity: 1
- item    : Basketball
  quantity: 4
- item    : Big Shoes
  quantity: 1
",
                Token.DirectivesEnd,
                Token.Comment,
                Token.BlockSeqBegin,
                Token.BlockMappingBegin,
                Token.ImplicitKey, "item",
                Token.ValueIndicator, "Super Hoop",
                Token.ImplicitKey, "quantity",
                Token.ValueIndicator, "1",
                Token.Outdent,
                Token.BlockSeqNext,
                Token.BlockMappingBegin, Token.ImplicitKey, "item",
                Token.ValueIndicator, "Basketball",
                Token.ImplicitKey, "quantity",
                Token.ValueIndicator, "4",
                Token.Outdent,
                Token.BlockSeqNext,
                Token.BlockMappingBegin, Token.ImplicitKey, "item",
                Token.ValueIndicator, "Big Shoes",
                Token.ImplicitKey, "quantity",
                Token.ValueIndicator, "1",
                Token.Outdent,
                Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_02_13()
        {
            YamlTest(@"
# ASCII Art
--- |
  \//||\/||
  // ||  ||__
", Token.Comment, Token.DirectivesEnd,
                     Token.Literal,
                     @"\//||\/||", Token.Newline, @"// ||  ||__", Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_02_14()
        {
            YamlTest(@"
---
  Mark McGwire's
  year was crippled
  by a knee injury.
",
                     Token.DirectivesEnd,
                     "Mark McGwire's",
                     Token.Newline,
                     "year was crippled",
                     Token.Newline,
                     "by a knee injury.",
                     Token.Newline
                );
        }

        [TestMethod]
        public void Y11_02_15()
        {
            YamlTest(
                @"
>
 Sammy Sosa completed another
 fine season with great stats.

   63 Home Runs
   0.288 Batting Average

 What a year!
",
                Token.Folded,
                "Sammy Sosa completed another", Token.Newline,
                "fine season with great stats.", Token.Newline, Token.Newline,
                Token.LeadingWhiteSpace, "63 Home Runs", Token.Newline,
                Token.LeadingWhiteSpace, "0.288 Batting Average", Token.Newline, Token.Newline,
                "What a year!",
                Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_02_16()
        {
            YamlTest(
                @"
name: Mark McGwire
accomplishment: >
  Mark set a major league
  home run record in 1998.
stats: |
  65 Home Runs
  0.278 Batting Average

",
                Token.BlockMappingBegin,
                Token.ImplicitKey, "name", Token.ValueIndicator, "Mark McGwire",
                Token.ImplicitKey, "accomplishment", Token.ValueIndicator,
                Token.Folded, "Mark set a major league", "home run record in 1998.",
                Token.Outdent,
                Token.ImplicitKey, "stats", Token.ValueIndicator,
                Token.Literal, "65 Home Runs", "0.278 Batting Average",
                Token.Outdent,
                Token.Outdent
                );
        }


        [TestMethod]
        public void Y11_02_17()
        {
            YamlTest(
                @"
unicode: ""Sosa did fine.\u263A""
control: ""\b1998\t1999\t2000\n""
hexesc:  ""\x0d\x0a is \r\n""

single: '""Howdy!"" he cried.'
quoted: ' # not a ''comment''.'
tie-fighter: '|\-*-/|'
",
                Token.BlockMappingBegin,
                Token.ImplicitKey, "unicode", Token.ValueIndicator, "Sosa did fine.", "\u263A",
                Token.ImplicitKey, "control", Token.ValueIndicator, "\b", "1998", "\t", "1999", "\t", "2000", "\n",
                Token.ImplicitKey, "hexesc", Token.ValueIndicator, "\x0d", "\x0a", " is ", "\r", "\n",
                Token.ImplicitKey, "single", Token.ValueIndicator, "\"Howdy!\" he cried.",
                Token.ImplicitKey, "quoted", Token.ValueIndicator, " # not a ",
                Token.EscapeWhiteSpace, "'", "comment", Token.EscapeWhiteSpace, "'", ".",
                Token.ImplicitKey, "tie-fighter", Token.ValueIndicator, @"|\-*-/|",
                Token.Outdent
                );
        }


        [TestMethod]
        public void Y11_02_18()
        {
            YamlTest(
                @"
plain:
  This unquoted scalar
  spans many lines.

quoted: ""So does this
  quoted scalar.\n""
",
                Token.BlockMappingBegin,
                Token.ImplicitKey, "plain", Token.ValueIndicator, "This unquoted scalar",
                Token.Newline, "spans many lines.", Token.Newline,
                Token.ImplicitKey, "quoted", Token.ValueIndicator, "So does this",
                Token.Newline, "quoted scalar.", "\n",
                Token.Outdent
                );
        }


        [TestMethod]
        public void Y11_02_27()
        {
            YamlTest(
                @"--- !<tag:clarkevans.com,2002:invoice>
invoice: 34843
date   : 2001-01-23
bill-to: &id001
    given  : Chris
    family : Dumars
    address:
        lines: |
            458 Walkman Dr.
            Suite #292
        city    : Royal Oak
        state   : MI
        postal  : 48046
ship-to: *id001
product:
    - sku         : BL394D
      quantity    : 4
      description : Basketball
      price       : 450.00
    - sku         : BL4438H
      quantity    : 1
      description : Super Hoop
      price       : 2392.00
tax  : 251.42
total: 4443.52
comments:
    Late afternoon is best.
    Backup contact is Nancy
    Billsmer @ 338-4338.
",
                Token.DirectivesEnd,
                Token.Tag,
                Token.BlockMappingBegin,
                Token.ImplicitKey, "invoice", Token.ValueIndicator, "34843",
                Token.ImplicitKey, "date", Token.ValueIndicator, "2001-01-23",
                Token.ImplicitKey, "bill-to",
                Token.ValueIndicator, Token.Anchor, Token.BlockMappingBegin,
                Token.ImplicitKey, "given", Token.ValueIndicator, "Chris",
                Token.ImplicitKey, "family", Token.ValueIndicator, "Dumars",
                Token.ImplicitKey, "address", Token.ValueIndicator,
                Token.BlockMappingBegin,
                Token.ImplicitKey, "lines", Token.ValueIndicator,
                Token.Literal, "458 Walkman Dr.", "Suite #292", Token.Outdent,
                Token.ImplicitKey, "city", Token.ValueIndicator, "Royal Oak",
                Token.ImplicitKey, "state", Token.ValueIndicator, "MI",
                Token.ImplicitKey, "postal", Token.ValueIndicator, "48046",
                Token.Outdent,
                Token.Outdent,
                Token.ImplicitKey, "ship-to", Token.ValueIndicator, Token.Alias,
                Token.ImplicitKey, "product", Token.ValueIndicator,
                Token.BlockSeqBegin,
                Token.BlockMappingBegin,
                Token.ImplicitKey, "sku", Token.ValueIndicator, "BL394D",
                Token.ImplicitKey, "quantity", Token.ValueIndicator, "4",
                Token.ImplicitKey, "description", Token.ValueIndicator, "Basketball",
                Token.ImplicitKey, "price", Token.ValueIndicator, "450.00",
                Token.Outdent,
                Token.BlockSeqNext, Token.BlockMappingBegin,
                Token.ImplicitKey, "sku", Token.ValueIndicator, "BL4438H",
                Token.ImplicitKey, "quantity", Token.ValueIndicator, "1",
                Token.ImplicitKey, "description", Token.ValueIndicator, "Super Hoop",
                Token.ImplicitKey, "price", Token.ValueIndicator, "2392.00",
                Token.Outdent,
                Token.Outdent,
                Token.ImplicitKey, "tax", Token.ValueIndicator, "251.42",
                Token.ImplicitKey, "total", Token.ValueIndicator, "4443.52",
                Token.ImplicitKey, "comments", Token.ValueIndicator,
                "Late afternoon is best.",
                "Backup contact is Nancy",
                "Billsmer @ 338-4338.",
                Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_09_01()
        {
            TraceTokens.Level = TraceLevel.Info;

            YamlTest(
                @"
""simple isKey"" : {  
  ""also simple"" : component,
  ? ""not a
  simple isKey"" : ""any
  component""
  }
",
                Token.BlockMappingBegin,
                Token.ImplicitKey, Token.DoubleQuote, "simple isKey", Token.ValueIndicator,
                Token.OpenBrace,
                Token.ImplicitKey, Token.DoubleQuote, "also simple", Token.DoubleQuote,
                Token.ValueIndicator, "component",
                Token.Comma,
                Token.FlowKeyIndicator, Token.DoubleQuote, "not a", "simple isKey", Token.DoubleQuote,
                Token.ValueIndicator, Token.DoubleQuote, "any", "component", Token.DoubleQuote,
                Token.CloseBrace,
                Token.Outdent
                );
        }


        [TestMethod]
        public void Y11_09_15()
        {
            YamlTest(@"
---
""---"" : foo
...: bar
---
[
---,
...,
{
? ---
: ...
}
]
...
",
                     Token.DirectivesEnd,
                     Token.BlockMappingBegin,
                     Token.ImplicitKey, "---",
                     Token.ValueIndicator, "foo",
                     Token.ImplicitKey, "...",
                     Token.ValueIndicator, "bar",
                     Token.Outdent,
                     Token.DirectivesEnd,
                     Token.OpenBracket,
                     "---", Token.Comma,
                     "...", Token.Comma,
                     Token.OpenBrace,
                     Token.FlowKeyIndicator, "---",
                     Token.ValueIndicator, "...",
                     Token.CloseBrace,
                     Token.CloseBracket,
                     Token.DocumentEnd
                );
        }

        [TestMethod]
        public void Y11_10_01()
        {
            YamlTest(@"
- [ inner, inner, ]
- [inner,last]
",
                     Token.BlockSeqBegin,
                     Token.OpenBracket,
                     "inner", Token.Comma,
                     "inner", Token.Comma,
                     Token.CloseBracket,
                     Token.BlockSeqNext,
                     Token.OpenBracket,
                     "inner", Token.Comma,
                     "last",
                     Token.CloseBracket,
                     Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_10_02()
        {
            YamlTest(
                @"
[
""double
 quoted"", 'single
           quoted',
plain
 text, [ nested ],
single: pair ,
]

",
                Token.OpenBracket,
                Token.DoubleQuote, "double", Token.Newline, "quoted", Token.DoubleQuote,
                Token.Comma,
                Token.SingleQuote, "single", Token.Newline, "quoted", Token.SingleQuote,
                Token.Comma,
                "plain", "text",
                Token.Comma,
                Token.OpenBracket, "nested", Token.CloseBracket,
                Token.Comma,
                Token.ImplicitKey, "single", Token.ValueIndicator, "pair",
                Token.Comma,
                Token.CloseBracket
                );
        }

        [TestMethod]
        public void Y11_10_03()
        {
            YamlTest(@"
block: # Block
       # sequence
- one
- two : three
",
                     Token.BlockMappingBegin,
                     Token.ImplicitKey, "block",
                     Token.ValueIndicator,
                     Token.Outdent, // Perhaps surprising, but parser will have to deal with this
                     Token.BlockSeqBegin, "one",
                     Token.BlockSeqNext, Token.BlockMappingBegin,
                     Token.ImplicitKey, "two",
                     Token.ValueIndicator, "three",
                     Token.Outdent,
                     Token.Outdent,
                     Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_10_04()
        {
            YamlTest(@"
block:
- one
-
 - two
",
                     Token.BlockMappingBegin,
                     Token.ImplicitKey, "block",
                     Token.ValueIndicator,
                     Token.Outdent, // Perhaps surprising, but parser will have to deal with this
                     Token.BlockSeqBegin, "one",
                     Token.BlockSeqNext,
                     Token.BlockSeqBegin, "two",
                     Token.Outdent,
                     Token.Outdent,
                     Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_10_05()
        {
            YamlTest(
                @"
- # Empty
- |
 block node
- - one # in-line
  - two # sequence
- one: two # in-line
           # mapping
",
                Token.BlockSeqBegin, Token.Outdent,
                Token.BlockSeqNext, Token.Literal, "block node", Token.Outdent,
                Token.BlockSeqNext,
                Token.BlockSeqBegin, "one",
                Token.BlockSeqNext, "two",
                Token.Outdent,
                Token.BlockSeqNext,
                Token.BlockMappingBegin,
                Token.ImplicitKey, "one",
                Token.ValueIndicator, "two",
                Token.Outdent,
                Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_10_06()
        {
            YamlTest(@"
- { inner : entry , also: inner , }
- {inner: entry,last : entry}
",
                     Token.BlockSeqBegin, Token.OpenBrace,
                     Token.ImplicitKey, "inner", Token.ValueIndicator, "entry", Token.Comma,
                     Token.ImplicitKey, "also", Token.ValueIndicator, "inner", Token.Comma,
                     Token.CloseBrace,
                     Token.BlockSeqNext,
                     Token.OpenBrace,
                     Token.ImplicitKey, "inner", Token.ValueIndicator, "entry", Token.Comma,
                     Token.ImplicitKey, "last", Token.ValueIndicator, "entry",
                     Token.CloseBrace,
                     Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_10_07()
        {
            YamlTest(
                @"
{
? : component, # Empty isKey
? explicit
 isKey: component,
simple isKey : component,
[ d, simple, isKey ]: component
}
",
                Token.OpenBrace,
                Token.FlowKeyIndicator,
                Token.ValueIndicator,
                "component",
                Token.Comma,
                Token.FlowKeyIndicator,
                "explicit", "isKey",
                Token.ValueIndicator,
                "component",
                Token.Comma,
                Token.ImplicitKey, "simple isKey",
                Token.ValueIndicator,
                "component",
                Token.Comma,
                Token.ImplicitKey, Token.OpenBracket,
                "d", Token.Comma,
                "simple", Token.Comma,
                "isKey",
                Token.CloseBracket,
                Token.ValueIndicator,
                "component",
                Token.CloseBrace
                );
        }


        [TestMethod]
        public void Y11_10_09()
        {
            YamlTest(@"
{
isKey : component,
empty: # empty component↓
}
",
                     Token.OpenBrace,
                     Token.ImplicitKey, "isKey",
                     Token.ValueIndicator, "component",
                     Token.Comma,
                     Token.ImplicitKey, "empty",
                     Token.ValueIndicator,
                     Token.CloseBrace
                );
        }

        [TestMethod]
        public void Y11_10_10()
        {
            YamlTest(
                @"
{
? explicit key1 : Explicit component,
? explicit key2 : , # Explicit empty
? explicit key3,     # Empty component
simple key1 : explicit component,
simple key2 : ,     # Explicit empty
simple key3,         # Empty component
} 
",
                Token.OpenBrace,
                Token.FlowKeyIndicator, "explicit key1",
                Token.ValueIndicator, "Explicit component",
                Token.Comma,
                Token.FlowKeyIndicator, "explicit key2",
                Token.ValueIndicator,
                Token.Comma,
                Token.FlowKeyIndicator, "explicit key3",
                Token.Comma,
                Token.ImplicitKey, "simple key1",
                Token.ValueIndicator, "explicit component",
                Token.Comma,
                Token.ImplicitKey, "simple key2",
                Token.ValueIndicator,
                Token.Comma,
                "simple key3",
                Token.Comma,
                Token.CloseBrace
                );
        }

        [TestMethod]
        public void Y11_10_11()
        {
            YamlTest(
                @"
[
? explicit key1 : Explicit component,
? explicit key2 : , # Explicit empty
? explicit key3,     # Empty component
simple key1 : explicit component,
simple key2 : ,     # Explicit empty
simple key3,         # Empty component
] 
",
                Token.OpenBracket,
                Token.FlowKeyIndicator, "explicit key1",
                Token.ValueIndicator, "Explicit component",
                Token.Comma,
                Token.FlowKeyIndicator, "explicit key2",
                Token.ValueIndicator,
                Token.Comma,
                Token.FlowKeyIndicator, "explicit key3",
                Token.Comma,
                Token.ImplicitKey, "simple key1",
                Token.ValueIndicator, "explicit component",
                Token.Comma,
                Token.ImplicitKey, "simple key2",
                Token.ValueIndicator,
                Token.Comma,
                "simple key3",
                Token.Comma,
                Token.CloseBracket
                );
        }

        [TestMethod]
        public void Y11_10_12()
        {
            YamlTest(@"
block: # Block    # mapping↓
 isKey: component
",
                     Token.BlockMappingBegin,
                     Token.ImplicitKey, "block", Token.ValueIndicator,
                     Token.BlockMappingBegin,
                     Token.ImplicitKey, "isKey",
                     Token.ValueIndicator, "component",
                     Token.Outdent,
                     Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_10_13()
        {
            YamlTest(
                @"
? explicit isKey # implicit component
? |
  block isKey
: - one # explicit in-line
  - two # block component
",
                Token.BlockMappingBegin,
                Token.BlockKeyIndicator,
                "explicit isKey",
                Token.BlockKeyIndicator, Token.Literal,
                "block isKey", Token.Outdent,
                Token.ValueIndicator,
                Token.BlockSeqBegin, "one",
                Token.BlockSeqNext, "two",
                Token.Outdent,
                Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_10_14()
        {
            YamlTest(
                @"
plain isKey: # empty component
""quoted isKey"":
- one # explicit next-line
- two # block component
",
                Token.BlockMappingBegin,
                Token.ImplicitKey, "plain isKey", Token.ValueIndicator, Token.Outdent,
                Token.ImplicitKey, Token.DoubleQuote, "quoted isKey", Token.DoubleQuote,
                Token.ValueIndicator,
                Token.Outdent, // Perhaps surprising, but parser will have to deal with this
                Token.BlockSeqBegin, "one",
                Token.BlockSeqNext, "two",
                Token.Outdent,
                Token.Outdent
                );
        }

        /// <summary>
        /// Tricky case that may look like a single mapping,
        /// but is really two nested mappings, with empty nodes...
        /// </summary>
        [TestMethod]
        public void Tricky1()
        {
            YamlTest(@"
---
? a : b
",
                     Token.DirectivesEnd,
                     Token.BlockMappingBegin,
                     Token.BlockKeyIndicator,
                     Token.BlockMappingBegin,
                     Token.ImplicitKey,
                     "a",
                     Token.ValueIndicator,
                     "b",
                     Token.Outdent,
                     Token.Outdent
                );
        }

        /// <summary>
        /// Block mapping with simple explicit isKey
        /// </summary>
        [TestMethod]
        public void ExplicitKey()
        {
            YamlTest(@"
---
? a 
: b
",
                     Token.DirectivesEnd,
                     Token.BlockMappingBegin,
                     Token.BlockKeyIndicator,
                     "a",
                     Token.ValueIndicator,
                     "b",
                     Token.Outdent
                );
        }

        [TestMethod]
        public void MixedMapping()
        {
            YamlTest(@"
---
? a: b
  c: d
: e: f
  g: h
",
                     Token.DirectivesEnd,
                     Token.BlockMappingBegin,
                     Token.BlockKeyIndicator,
                     Token.BlockMappingBegin,
                     Token.ImplicitKey,
                     "a",
                     Token.ValueIndicator,
                     "b",
                     Token.ImplicitKey,
                     "c",
                     Token.ValueIndicator,
                     "d",
                     Token.Outdent,
                     Token.ValueIndicator,
                     Token.BlockMappingBegin,
                     Token.ImplicitKey,
                     "e",
                     Token.ValueIndicator,
                     "f",
                     Token.ImplicitKey,
                     "g",
                     Token.ValueIndicator,
                     "h",
                     Token.Outdent,
                     Token.Outdent
                );
        }

        [TestMethod]
        public void Y11_10_15()
        {
            YamlTest(@"
- sun: yellow
- ? earth: blue
  : moon: white
",
                     Token.BlockSeqBegin,
                     Token.BlockMappingBegin,
                     Token.ImplicitKey, "sun", Token.ValueIndicator, "yellow",
                     Token.Outdent,
                     Token.BlockSeqNext,
                     Token.BlockMappingBegin,
                     Token.BlockKeyIndicator,
                     Token.BlockMappingBegin,
                     Token.ImplicitKey, "earth",
                     Token.ValueIndicator, "blue",
                     Token.Outdent,
                     Token.ValueIndicator,
                     Token.BlockMappingBegin,
                     Token.ImplicitKey, "moon",
                     Token.ValueIndicator, "white",
                     Token.Outdent,
                     Token.Outdent,
                     Token.Outdent
                );
        }

        // ReSharper restore InconsistentNaming
    }
}